﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Collections;
using System.Data;

namespace 多线程
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.Run(new 异步处理());

            //设置表的列顺序
            DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("t1",typeof(string)));
            DataColumn dc=new DataColumn("t2",typeof(string));
            dt.Columns.Add(dc);
            DataColumn dd = new DataColumn("t3", typeof(DateTime));
            dt.Columns.Add(dd);

            DataRow dr = dt.NewRow();
            dr["t3"] = DBNull.Value;
            dt.Rows.Add(dr);

            dc.SetOrdinal(0);

            string abc = "sdfjskfdjlksjfd";

            char[] asp = abc.ToCharArray();
            List<MyObj> objs = new List<MyObj>();
            objs.Add(new MyObj(3, "3士大rt夫"));
            objs.Add(new MyObj(5, "3e"));
            objs.Add(new MyObj(67, "3士大"));
            objs.Add(new MyObj(2, "3sdf "));
            objs.Add(new MyObj(56, "3er"));

            objs.Sort(new MyComparer<MyObj>());

            string SS = "";
            for (int I = 0; I < objs.Count; I++)
            {
                SS += objs[I].Id.ToString() + "--";
            }
            MessageBox.Show(SS);
        }
    }


    public class MyComparer<T> : IComparer<T>
    {
        int IComparer<T>.Compare(T x, T y)
        {
                MyObj A1 = x as MyObj;
                MyObj A2 = y as MyObj;
                if (A1.Id > A2.Id)
                    return -1;
                else if (A1.Id < A2.Id)
                    return 1;
                else 
                    return 0;
        }
    }

    public class MyObj
    {
        private int _id;

        public int Id
        {
            get { return _id; }
            set { _id = value; }
        }
        private string _name;

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public MyObj(int id, string name)
        {
            _id = id;
            _name = name;
        }

    }
}